package com.lys.emsystem.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lys.emsystem.entity.LoginLog;
import com.lys.emsystem.service.ILoginLogService;
import com.lys.emsystem.utils.Result;
import com.lys.emsystem.vo.LoginLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liyansheng
 * @since 2022-05-06
 */
@RestController
@CrossOrigin
@RequestMapping("/login-log")
public class LoginLogController {
    @Autowired
    private ILoginLogService loginLogService;

    @PostMapping
    public Result search(@RequestBody LoginLogVo loginLogVo) {
        return loginLogService.search(new Page(loginLogVo.getPageIndex(), loginLogVo.getPageSize()), loginLogVo);
    }

    @PostMapping("/delete/{id}")
    public Result del(@PathVariable("id") Integer id) {
        if (loginLogService.removeById(id)) {
            return Result.buildResult(Result.Status.OK);
        }
        return Result.buildResult(Result.Status.ERROR, "删除出错！");
    }


}
